package com.eShopManager.intigration.ebay;

import com.ebay.sdk.ApiAccount;
import com.ebay.sdk.ApiContext;
import com.ebay.sdk.ApiCredential;
import com.ebay.sdk.util.SdkProxySelector;

public class ApiContextCache {

	private ApiContext apiContext = null;

	private String runame;
	private String devId;
	private String appId;
	private String certId;
	private String ebayAPIUrl;
	private String ebaySignInUrl;

	public void setEbaySignInUrl(String ebaySignInUrl) {
		this.ebaySignInUrl = ebaySignInUrl;
	}

	public void setRuname(String runame) {
		this.runame = runame;
	}

	public void setDevId(String devId) {
		this.devId = devId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public void setCertId(String certId) {
		this.certId = certId;
	}

	public void setEbayAPIUrl(String ebayAPIUrl) {
		this.ebayAPIUrl = ebayAPIUrl;
	}

	public void init() {
		ApiAccount ac = new ApiAccount();
		ac.setDeveloper(devId);
		ac.setApplication(appId);
		ac.setCertificate(certId);

		ApiCredential apiCred = new ApiCredential();
		apiCred.setApiAccount(ac);

		apiContext = new ApiContext();
		apiContext.setApiCredential(apiCred);
		apiContext.setApiServerUrl(ebayAPIUrl);
		SdkProxySelector ps = new SdkProxySelector("10.0.0.1", 80);
		ps.register();
	}

	public ApiContext getApiContext() {
		return this.apiContext;
	}

	public String getRuname() {
		return this.runame;
	}

	public String getEbaySignInUrl() {
		return this.ebaySignInUrl;
	}

}
